<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-validator-behavior/iron-validator-behavior.html">
<script>
    Polymer({

        is: 'log-target-validator',

        behaviors: [
            Polymer.IronValidatorBehavior
        ],

        validate: function (str) {
            if (!str) {
                return false;
            }
            var allKeysMissing;
            var index;
            var keys = ['user_id', 'owner_id', 'cloud_id', 'machine_id', 'rule_id', 'stack_id', 'template_id', 'schedule_id', 'script_id', 'volume_id', 'key_id', 'job_id', 'shell_id', 'session_id', 'incident_id', 'job', 'action', 'error', 'type'];
            var allKeysMissing = keys.every(function(key,ind){
                index = ind;
                return str.indexOf(key+":") == -1;
            })
            if (allKeysMissing) {
                return false;
            }
            // TODO: check whether keys have values
            return !allKeysMissing;
        }

    });
</script>